Imports System 
Imports System.Text 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Common
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Configuration 
Imports System.Xml 
Imports System.Xml.Serialization
Imports SubSonic 
Imports SubSonic.Utilities
Namespace Data
	''' <summary>
	''' Strongly-typed collection for the AspnetWebEventEvents class.
	''' </summary>
	<Serializable> _
	Public Partial Class AspnetWebEventEventsCollection 
	Inherits ActiveList(Of AspnetWebEventEvents, AspnetWebEventEventsCollection)
	    Public Sub New()
		End Sub
	End Class
	''' <summary>
	''' This is an ActiveRecord class which wraps the aspnet_WebEvent_Events table.
	''' </summary>
	<Serializable> _
	Public Partial Class AspnetWebEventEvents 
	Inherits ActiveRecord(Of AspnetWebEventEvents)
		#Region ".ctors and Default Settings"
		
		Public Sub New()
			SetSQLProps()
			InitSetDefaults()
			MarkNew()
		End Sub
		
		Public Sub New(ByVal useDatabaseDefaults As Boolean)
			SetSQLProps()
			If useDatabaseDefaults = True Then
				ForceDefaults()
			End If
			MarkNew()
		End Sub
		Public Sub New(ByVal keyID As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByKey(keyID)
		End Sub
		Public Sub New(ByVal columnName As String, ByVal columnValue As Object)
			SetSQLProps()
			InitSetDefaults()
			LoadByParam(columnName,columnValue)
		End Sub
		Private Sub InitSetDefaults()
			SetDefaults()
		End Sub
		
		Protected Shared Sub SetSQLProps()
			GetTableSchema()
		End Sub
		#End Region
		
		#Region "Schema and Query Accessor"
		
		Public Shared ReadOnly Property Schema() As TableSchema.Table
			Get
				If BaseSchema Is Nothing Then
					SetSQLProps()
				End If
				Return BaseSchema
			End Get
		End Property
		Private Shared Sub GetTableSchema()
			If (Not IsSchemaInitialized) Then
				'Schema declaration
				Dim schema As TableSchema.Table = New TableSchema.Table("aspnet_WebEvent_Events", TableType.Table, DataService.GetInstance("ClubStarterKitData"))
				schema.Columns = New TableSchema.TableColumnCollection()
				schema.SchemaName = "dbo"
				'columns
				
                
                Dim colvarEventId As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEventId.ColumnName = "EventId"
                colvarEventId.DataType = DbType.AnsiStringFixedLength
                colvarEventId.MaxLength = 32
                colvarEventId.AutoIncrement = false
                colvarEventId.IsNullable = false
                colvarEventId.IsPrimaryKey = true
                colvarEventId.IsForeignKey = false
                colvarEventId.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEventId)
                
                Dim colvarEventTimeUtc As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEventTimeUtc.ColumnName = "EventTimeUtc"
                colvarEventTimeUtc.DataType = DbType.DateTime
                colvarEventTimeUtc.MaxLength = 0
                colvarEventTimeUtc.AutoIncrement = false
                colvarEventTimeUtc.IsNullable = false
                colvarEventTimeUtc.IsPrimaryKey = false
                colvarEventTimeUtc.IsForeignKey = false
                colvarEventTimeUtc.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEventTimeUtc)
                
                Dim colvarEventTime As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEventTime.ColumnName = "EventTime"
                colvarEventTime.DataType = DbType.DateTime
                colvarEventTime.MaxLength = 0
                colvarEventTime.AutoIncrement = false
                colvarEventTime.IsNullable = false
                colvarEventTime.IsPrimaryKey = false
                colvarEventTime.IsForeignKey = false
                colvarEventTime.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEventTime)
                
                Dim colvarEventType As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEventType.ColumnName = "EventType"
                colvarEventType.DataType = DbType.String
                colvarEventType.MaxLength = 256
                colvarEventType.AutoIncrement = false
                colvarEventType.IsNullable = false
                colvarEventType.IsPrimaryKey = false
                colvarEventType.IsForeignKey = false
                colvarEventType.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEventType)
                
                Dim colvarEventSequence As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEventSequence.ColumnName = "EventSequence"
                colvarEventSequence.DataType = DbType.Decimal
                colvarEventSequence.MaxLength = 0
                colvarEventSequence.AutoIncrement = false
                colvarEventSequence.IsNullable = false
                colvarEventSequence.IsPrimaryKey = false
                colvarEventSequence.IsForeignKey = false
                colvarEventSequence.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEventSequence)
                
                Dim colvarEventOccurrence As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEventOccurrence.ColumnName = "EventOccurrence"
                colvarEventOccurrence.DataType = DbType.Decimal
                colvarEventOccurrence.MaxLength = 0
                colvarEventOccurrence.AutoIncrement = false
                colvarEventOccurrence.IsNullable = false
                colvarEventOccurrence.IsPrimaryKey = false
                colvarEventOccurrence.IsForeignKey = false
                colvarEventOccurrence.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEventOccurrence)
                
                Dim colvarEventCode As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEventCode.ColumnName = "EventCode"
                colvarEventCode.DataType = DbType.Int32
                colvarEventCode.MaxLength = 0
                colvarEventCode.AutoIncrement = false
                colvarEventCode.IsNullable = false
                colvarEventCode.IsPrimaryKey = false
                colvarEventCode.IsForeignKey = false
                colvarEventCode.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEventCode)
                
                Dim colvarEventDetailCode As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarEventDetailCode.ColumnName = "EventDetailCode"
                colvarEventDetailCode.DataType = DbType.Int32
                colvarEventDetailCode.MaxLength = 0
                colvarEventDetailCode.AutoIncrement = false
                colvarEventDetailCode.IsNullable = false
                colvarEventDetailCode.IsPrimaryKey = false
                colvarEventDetailCode.IsForeignKey = false
                colvarEventDetailCode.IsReadOnly = false
                
                
                schema.Columns.Add(colvarEventDetailCode)
                
                Dim colvarMessage As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarMessage.ColumnName = "Message"
                colvarMessage.DataType = DbType.String
                colvarMessage.MaxLength = 1024
                colvarMessage.AutoIncrement = false
                colvarMessage.IsNullable = true
                colvarMessage.IsPrimaryKey = false
                colvarMessage.IsForeignKey = false
                colvarMessage.IsReadOnly = false
                
                
                schema.Columns.Add(colvarMessage)
                
                Dim colvarApplicationPath As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarApplicationPath.ColumnName = "ApplicationPath"
                colvarApplicationPath.DataType = DbType.String
                colvarApplicationPath.MaxLength = 256
                colvarApplicationPath.AutoIncrement = false
                colvarApplicationPath.IsNullable = true
                colvarApplicationPath.IsPrimaryKey = false
                colvarApplicationPath.IsForeignKey = false
                colvarApplicationPath.IsReadOnly = false
                
                
                schema.Columns.Add(colvarApplicationPath)
                
                Dim colvarApplicationVirtualPath As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarApplicationVirtualPath.ColumnName = "ApplicationVirtualPath"
                colvarApplicationVirtualPath.DataType = DbType.String
                colvarApplicationVirtualPath.MaxLength = 256
                colvarApplicationVirtualPath.AutoIncrement = false
                colvarApplicationVirtualPath.IsNullable = true
                colvarApplicationVirtualPath.IsPrimaryKey = false
                colvarApplicationVirtualPath.IsForeignKey = false
                colvarApplicationVirtualPath.IsReadOnly = false
                
                
                schema.Columns.Add(colvarApplicationVirtualPath)
                
                Dim colvarMachineName As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarMachineName.ColumnName = "MachineName"
                colvarMachineName.DataType = DbType.String
                colvarMachineName.MaxLength = 256
                colvarMachineName.AutoIncrement = false
                colvarMachineName.IsNullable = false
                colvarMachineName.IsPrimaryKey = false
                colvarMachineName.IsForeignKey = false
                colvarMachineName.IsReadOnly = false
                
                
                schema.Columns.Add(colvarMachineName)
                
                Dim colvarRequestUrl As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarRequestUrl.ColumnName = "RequestUrl"
                colvarRequestUrl.DataType = DbType.String
                colvarRequestUrl.MaxLength = 1024
                colvarRequestUrl.AutoIncrement = false
                colvarRequestUrl.IsNullable = true
                colvarRequestUrl.IsPrimaryKey = false
                colvarRequestUrl.IsForeignKey = false
                colvarRequestUrl.IsReadOnly = false
                
                
                schema.Columns.Add(colvarRequestUrl)
                
                Dim colvarExceptionType As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarExceptionType.ColumnName = "ExceptionType"
                colvarExceptionType.DataType = DbType.String
                colvarExceptionType.MaxLength = 256
                colvarExceptionType.AutoIncrement = false
                colvarExceptionType.IsNullable = true
                colvarExceptionType.IsPrimaryKey = false
                colvarExceptionType.IsForeignKey = false
                colvarExceptionType.IsReadOnly = false
                
                
                schema.Columns.Add(colvarExceptionType)
                
                Dim colvarDetails As TableSchema.TableColumn = New TableSchema.TableColumn(schema)
                colvarDetails.ColumnName = "Details"
                colvarDetails.DataType = DbType.String
                colvarDetails.MaxLength = 1073741823
                colvarDetails.AutoIncrement = false
                colvarDetails.IsNullable = true
                colvarDetails.IsPrimaryKey = false
                colvarDetails.IsForeignKey = false
                colvarDetails.IsReadOnly = false
                
                
                schema.Columns.Add(colvarDetails)
                
				BaseSchema = schema
				
				'add this schema to the provider
                'so we can query it later
                DataService.Providers("ClubStarterKitData").AddSchema("aspnet_WebEvent_Events",schema)
			End If
		End Sub
		Public Shared Function CreateQuery() As Query
			Return New Query(Schema)
		End Function
		
		#End Region
		
		#Region "Props"
	
          
        <XmlAttribute("EventId")> _
        Public Property EventId As String 
			Get
				Return GetColumnValue(Of String)("EventId")
			End Get
		    
			Set
				SetColumnValue("EventId", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("EventTimeUtc")> _
        Public Property EventTimeUtc As DateTime 
			Get
				Return GetColumnValue(Of DateTime)("EventTimeUtc")
			End Get
		    
			Set
				SetColumnValue("EventTimeUtc", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("EventTime")> _
        Public Property EventTime As DateTime 
			Get
				Return GetColumnValue(Of DateTime)("EventTime")
			End Get
		    
			Set
				SetColumnValue("EventTime", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("EventType")> _
        Public Property EventType As String 
			Get
				Return GetColumnValue(Of String)("EventType")
			End Get
		    
			Set
				SetColumnValue("EventType", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("EventSequence")> _
        Public Property EventSequence As Decimal 
			Get
				Return GetColumnValue(Of Decimal)("EventSequence")
			End Get
		    
			Set
				SetColumnValue("EventSequence", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("EventOccurrence")> _
        Public Property EventOccurrence As Decimal 
			Get
				Return GetColumnValue(Of Decimal)("EventOccurrence")
			End Get
		    
			Set
				SetColumnValue("EventOccurrence", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("EventCode")> _
        Public Property EventCode As Integer 
			Get
				Return GetColumnValue(Of Integer)("EventCode")
			End Get
		    
			Set
				SetColumnValue("EventCode", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("EventDetailCode")> _
        Public Property EventDetailCode As Integer 
			Get
				Return GetColumnValue(Of Integer)("EventDetailCode")
			End Get
		    
			Set
				SetColumnValue("EventDetailCode", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Message")> _
        Public Property Message As String 
			Get
				Return GetColumnValue(Of String)("Message")
			End Get
		    
			Set
				SetColumnValue("Message", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("ApplicationPath")> _
        Public Property ApplicationPath As String 
			Get
				Return GetColumnValue(Of String)("ApplicationPath")
			End Get
		    
			Set
				SetColumnValue("ApplicationPath", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("ApplicationVirtualPath")> _
        Public Property ApplicationVirtualPath As String 
			Get
				Return GetColumnValue(Of String)("ApplicationVirtualPath")
			End Get
		    
			Set
				SetColumnValue("ApplicationVirtualPath", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("MachineName")> _
        Public Property MachineName As String 
			Get
				Return GetColumnValue(Of String)("MachineName")
			End Get
		    
			Set
				SetColumnValue("MachineName", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("RequestUrl")> _
        Public Property RequestUrl As String 
			Get
				Return GetColumnValue(Of String)("RequestUrl")
			End Get
		    
			Set
				SetColumnValue("RequestUrl", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("ExceptionType")> _
        Public Property ExceptionType As String 
			Get
				Return GetColumnValue(Of String)("ExceptionType")
			End Get
		    
			Set
				SetColumnValue("ExceptionType", Value)
			End Set
		End Property
		
		
		  
        <XmlAttribute("Details")> _
        Public Property Details As String 
			Get
				Return GetColumnValue(Of String)("Details")
			End Get
		    
			Set
				SetColumnValue("Details", Value)
			End Set
		End Property
		
		
		
		
		#End Region
		
		
			    
	    
		
		
		
		
		
	    
	    'no foreign key tables defined (0)
	    
		
	    
	    'no ManyToMany tables defined (0)
	    
		
		#Region "ObjectDataSource support"
		
		''' <summary>
		''' Inserts a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Insert(ByVal varEventId As String,ByVal varEventTimeUtc As DateTime,ByVal varEventTime As DateTime,ByVal varEventType As String,ByVal varEventSequence As Decimal,ByVal varEventOccurrence As Decimal,ByVal varEventCode As Integer,ByVal varEventDetailCode As Integer,ByVal varMessage As String,ByVal varApplicationPath As String,ByVal varApplicationVirtualPath As String,ByVal varMachineName As String,ByVal varRequestUrl As String,ByVal varExceptionType As String,ByVal varDetails As String)
			Dim item As AspnetWebEventEvents = New AspnetWebEventEvents()
			
            item.EventId = varEventId
            
            item.EventTimeUtc = varEventTimeUtc
            
            item.EventTime = varEventTime
            
            item.EventType = varEventType
            
            item.EventSequence = varEventSequence
            
            item.EventOccurrence = varEventOccurrence
            
            item.EventCode = varEventCode
            
            item.EventDetailCode = varEventDetailCode
            
            item.Message = varMessage
            
            item.ApplicationPath = varApplicationPath
            
            item.ApplicationVirtualPath = varApplicationVirtualPath
            
            item.MachineName = varMachineName
            
            item.RequestUrl = varRequestUrl
            
            item.ExceptionType = varExceptionType
            
            item.Details = varDetails
            
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		''' <summary>
		''' Updates a record, can be used with the Object Data Source
		''' </summary>
		Public Shared Sub Update(ByVal varEventId As String,ByVal varEventTimeUtc As DateTime,ByVal varEventTime As DateTime,ByVal varEventType As String,ByVal varEventSequence As Decimal,ByVal varEventOccurrence As Decimal,ByVal varEventCode As Integer,ByVal varEventDetailCode As Integer,ByVal varMessage As String,ByVal varApplicationPath As String,ByVal varApplicationVirtualPath As String,ByVal varMachineName As String,ByVal varRequestUrl As String,ByVal varExceptionType As String,ByVal varDetails As String)
			Dim item As AspnetWebEventEvents = New AspnetWebEventEvents()
		    
                item.EventId = varEventId
				
                item.EventTimeUtc = varEventTimeUtc
				
                item.EventTime = varEventTime
				
                item.EventType = varEventType
				
                item.EventSequence = varEventSequence
				
                item.EventOccurrence = varEventOccurrence
				
                item.EventCode = varEventCode
				
                item.EventDetailCode = varEventDetailCode
				
                item.Message = varMessage
				
                item.ApplicationPath = varApplicationPath
				
                item.ApplicationVirtualPath = varApplicationVirtualPath
				
                item.MachineName = varMachineName
				
                item.RequestUrl = varRequestUrl
				
                item.ExceptionType = varExceptionType
				
                item.Details = varDetails
				
			item.IsNew = False
			If Not System.Web.HttpContext.Current Is Nothing Then
				item.Save(System.Web.HttpContext.Current.User.Identity.Name)
			Else
				item.Save(System.Threading.Thread.CurrentPrincipal.Identity.Name)
			End If
		End Sub
		#End Region
		#Region "Columns Struct"
		Public Structure Columns
			Dim x as Integer
			
            Public Shared EventId As String = "EventId"
            
            Public Shared EventTimeUtc As String = "EventTimeUtc"
            
            Public Shared EventTime As String = "EventTime"
            
            Public Shared EventType As String = "EventType"
            
            Public Shared EventSequence As String = "EventSequence"
            
            Public Shared EventOccurrence As String = "EventOccurrence"
            
            Public Shared EventCode As String = "EventCode"
            
            Public Shared EventDetailCode As String = "EventDetailCode"
            
            Public Shared Message As String = "Message"
            
            Public Shared ApplicationPath As String = "ApplicationPath"
            
            Public Shared ApplicationVirtualPath As String = "ApplicationVirtualPath"
            
            Public Shared MachineName As String = "MachineName"
            
            Public Shared RequestUrl As String = "RequestUrl"
            
            Public Shared ExceptionType As String = "ExceptionType"
            
            Public Shared Details As String = "Details"
            
		End Structure
		#End Region
	End Class
End Namespace
